﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using HuaCheng.DataAccess;

namespace HuaCheng.Views
{
    public partial class FrmWaiting : Form
    {
        public FrmWaiting(string msg)
        {
            InitializeComponent();
            //注册初始化和修改进度条值的委托监听
            ChannelDataHelper.InitProcessBarStep += new ChannelDataHelper.InitProcessBar(InitProgressStep);
            ChannelDataHelper.AddProcessBarStep += new ChannelDataHelper.AddProcessBar(Addprogess);
            this.lblMsg.Text = msg;
        }
        #region 进度条相关操作
        public void Addprogess()
        {
            progressBar.PerformStep();
        }
        public void InitProgressStep(int max,int x)
        {
            if (max / x == 0)
            {
                progressBar.Maximum = 1;
            }
            else
            {
                if (max % x == 0)
                {
                    progressBar.Maximum = max / x;
                }
                else
                {
                    progressBar.Maximum = max / x + 1;
                }
            }
           
            progressBar.Step = 1;
        }
        #endregion
    }
}
